<?php
    get_header();
?>

<div id="content">
	
	<?php
		if( is_search() ) {
			global $s;
			echo "<h1>Search Results for '" . $s . "'</h1>";
		} elseif( is_archive() && !is_author() ) {
			echo "<h1>Articles tagged with '" . wp_title( '', false, 'right' ) . "'</h1>";
		}
		
		if( !is_singular() && !is_search() ) {
			global $more;
		}
	?>
	
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
        <h2>
            <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
                <?php the_title(); ?>
            </a>
        </h2>
        
        <div class="authoring-info">
            by <?php the_author_posts_link(); ?>  <span><?php the_time('F j, Y'); ?> at <?php the_time('g:i A'); ?></span>
            <ul>
                <li class="first">Tags:&nbsp</li>
                <?php
                        the_tags('<li>', 
                                 ',&nbsp</li><li>',
                                 '</li>');
                ?>
            </ul>
        </div>
        
        <div class="post-content">			
            <?php 
				if( is_search() ) {
					the_excerpt();
				} else {
					
					if( !is_singular() && !is_search() && strpos($post->post_content, '<!--more-->')) {
						//This is to split the post into two parts:
						//before the "more" tag and after
						//This way, we render the entire post content
						//and can show/hide the after-more stuff in the JS
						//-Lev
						$more = 0;
						echo '<div class="post-part1">';
						the_content('');
						echo '</div>';
						echo '<a class="more-link" href="#">Read more &raquo;</a>';
						echo '<div class="post-part2-loader"><img src="/wp-content/themes/SPUD/images/loader_24p.gif" /></div>';
						$more = 1;
						echo '<div class="post-part2">';
						//the_content('', TRUE, '');
						echo '</div>';
					} else {
						the_content();
					}
					
				} 
			?>
        </div>
        <div class="post-comment-controls">
			<a class="comment-toggle">
			<?php
				comments_indicator();
			?>
			</a>
            <a title="Hide" class="comment-toggle indicator">Hide</a>
            <!-- icons for fb, delicious, twitter, tumblr, etc. -->
            <ul>
                <li class="user-touchpoint facebook"><a title="Share on Facebook" href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>"><span>Share on Facebook</span></a></li>
                <li class="user-touchpoint delicious"><a title="Share on Delicious" href="http://del.icio.us/post?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>"><span>Share on Delicious</span></a></li>
                <li class="user-touchpoint twitter"><a title="Share on Twitter" href="http://twitter.com/home?status=RT%20<?php the_title(); ?>%20<?php the_permalink(); ?>"><span>Share on Twitter</span></a></li>
                <li class="user-touchpoint digg"><a title="Share on Digg" href="http://digg.com/submit?phase=2&amp;url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>"><span>Share on Digg</span></a></li>
            </ul>
        </div>
        <?php
 			//if( is_front_page() ) {
				$withcomments = 1; /*setting this to have comments on the index page -Lev*/
			//} 
			comments_template();
		?>
    </div>
    
    <?php endwhile; else: ?>
    <p>
      <?php _e('Sorry, no posts matched your criteria.'); ?>
    </p>
    <?php endif; ?>

	<div class="posts-nav">
		<div class="left"><?php next_posts_link('&larr; Older Posts', 0); ?></div>
    	<div class="right"> <?php previous_posts_link('Newer Posts &rarr;', 0); ?></div>
	</div>
</div>

<?php
    get_sidebar();
    get_footer();
?>